<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>报警管理 - Modbus监控系统</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Microsoft YaHei', Arial, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            padding: 20px;
        }

        .container {
            max-width: 1400px;
            margin: 0 auto;
        }

        .header {
            background: white;
            padding: 20px 30px;
            border-radius: 10px;
            margin-bottom: 20px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }

        .header h1 {
            font-size: 24px;
            color: #333;
            margin-bottom: 15px;
        }

        .toolbar {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .btn {
            padding: 10px 20px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 14px;
            font-weight: 500;
            transition: all 0.3s;
        }

        .btn-primary {
            background: #3b82f6;
            color: white;
        }

        .btn-primary:hover {
            background: #2563eb;
        }

        .btn-danger {
            background: #ef4444;
            color: white;
        }

        .btn-danger:hover {
            background: #dc2626;
        }

        .alarm-stats {
            display: flex;
            gap: 20px;
            font-size: 14px;
        }

        .stat-item {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .stat-badge {
            display: inline-block;
            padding: 4px 12px;
            border-radius: 15px;
            font-weight: bold;
        }

        .stat-badge.critical {
            background: #fee2e2;
            color: #991b1b;
        }

        .stat-badge.warning {
            background: #fef3c7;
            color: #92400e;
        }

        .stat-badge.info {
            background: #dbeafe;
            color: #1e40af;
        }

        .content-grid {
            display: grid;
            grid-template-columns: 2fr 1fr;
            gap: 20px;
            margin-bottom: 20px;
        }

        .alarm-list-container {
            background: white;
            border-radius: 10px;
            padding: 20px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }

        .section-title {
            font-size: 18px;
            font-weight: bold;
            color: #333;
            margin-bottom: 20px;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .alarm-item {
            border-left: 4px solid #ddd;
            padding: 15px;
            margin-bottom: 15px;
            background: #f8fafc;
            border-radius: 0 8px 8px 0;
            transition: all 0.3s;
        }

        .alarm-item:hover {
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
            transform: translateX(5px);
        }

        .alarm-item.critical {
            border-left-color: #ef4444;
            background: #fef2f2;
        }

        .alarm-item.warning {
            border-left-color: #f59e0b;
            background: #fffbeb;
        }

        .alarm-item.info {
            border-left-color: #3b82f6;
            background: #eff6ff;
        }

        .alarm-header {
            display: flex;
            justify-content: space-between;
            align-items: start;
            margin-bottom: 10px;
        }

        .alarm-title {
            font-size: 16px;
            font-weight: bold;
            color: #333;
        }

        .alarm-level {
            padding: 3px 10px;
            border-radius: 12px;
            font-size: 12px;
            font-weight: bold;
        }

        .alarm-level.critical {
            background: #ef4444;
            color: white;
        }

        .alarm-level.warning {
            background: #f59e0b;
            color: white;
        }

        .alarm-level.info {
            background: #3b82f6;
            color: white;
        }

        .alarm-details {
            color: #666;
            font-size: 14px;
            line-height: 1.6;
        }

        .alarm-time {
            color: #999;
            font-size: 13px;
            margin-top: 8px;
        }

        .alarm-actions {
            margin-top: 10px;
            display: flex;
            gap: 10px;
        }

        .btn-small {
            padding: 5px 12px;
            font-size: 12px;
            border: 1px solid #ddd;
            background: white;
            border-radius: 4px;
            cursor: pointer;
            transition: all 0.3s;
        }

        .btn-small:hover {
            background: #f3f4f6;
        }

        .threshold-settings {
            background: white;
            border-radius: 10px;
            padding: 20px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }

        .threshold-item {
            padding: 15px;
            background: #f8fafc;
            border-radius: 8px;
            margin-bottom: 15px;
        }

        .threshold-label {
            font-size: 14px;
            color: #666;
            margin-bottom: 10px;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .threshold-input {
            display: flex;
            gap: 10px;
            align-items: center;
        }

        .threshold-input input {
            flex: 1;
            padding: 8px;
            border: 2px solid #e5e7eb;
            border-radius: 5px;
            font-size: 14px;
        }

        .threshold-input input:focus {
            outline: none;
            border-color: #3b82f6;
        }

        .threshold-input span {
            color: #999;
            font-size: 14px;
        }

        .filter-tabs {
            display: flex;
            gap: 5px;
            margin-bottom: 20px;
            border-bottom: 2px solid #e5e7eb;
        }

        .tab {
            padding: 10px 20px;
            background: transparent;
            border: none;
            border-bottom: 3px solid transparent;
            cursor: pointer;
            font-size: 14px;
            color: #666;
            transition: all 0.3s;
        }

        .tab:hover {
            color: #3b82f6;
        }

        .tab.active {
            color: #3b82f6;
            border-bottom-color: #3b82f6;
            font-weight: bold;
        }

        .empty-state {
            text-align: center;
            padding: 60px 20px;
            color: #9ca3af;
        }

        .empty-icon {
            font-size: 64px;
            margin-bottom: 20px;
        }
    </style>
</head>

<body>
    <div class="container">
        <!-- 顶部工具栏 -->
        <div class="header">
            <h1>🚨 报警管理</h1>
            <div class="toolbar">
                <div class="alarm-stats">
                    <div class="stat-item">
                        <span>严重：</span>
                        <span class="stat-badge critical">3</span>
                    </div>
                    <div class="stat-item">
                        <span>警告：</span>
                        <span class="stat-badge warning">7</span>
                    </div>
                    <div class="stat-item">
                        <span>信息：</span>
                        <span class="stat-badge info">12</span>
                    </div>
                </div>
                <div style="display: flex; gap: 10px;">
                    <button class="btn btn-primary">🔔 全部标记已读</button>
                    <button class="btn btn-primary">📥 导出报警记录</button>
                </div>
            </div>
        </div>

        <!-- 主内容区 -->
        <div class="content-grid">
            <!-- 左侧：报警列表 -->
            <div class="alarm-list-container">
                <div class="section-title">
                    📋 报警记录
                </div>

                <!-- 筛选标签 -->
                <div class="filter-tabs">
                    <button class="tab active">全部 (22)</button>
                    <button class="tab">严重 (3)</button>
                    <button class="tab">警告 (7)</button>
                    <button class="tab">信息 (12)</button>
                    <button class="tab">已处理 (158)</button>
                </div>

                <!-- 报警项 -->
                <div class="alarm-list">
                    <!-- 严重报警 -->
                    <div class="alarm-item critical">
                        <div class="alarm-header">
                            <div class="alarm-title">⚠️ 温度过高报警</div>
                            <div class="alarm-level critical">严重</div>
                        </div>
                        <div class="alarm-details">
                            设备: <strong>PLC_01</strong><br>
                            当前温度: <strong style="color: #ef4444;">75.3℃</strong> (阈值: 70.0℃)<br>
                            持续时间: 5分32秒
                        </div>
                        <div class="alarm-time">⏰ 2025-10-29 14:52:18</div>
                        <div class="alarm-actions">
                            <button class="btn-small">✓ 标记已处理</button>
                            <button class="btn-small">📊 查看数据</button>
                        </div>
                    </div>

                    <div class="alarm-item critical">
                        <div class="alarm-header">
                            <div class="alarm-title">⚠️ 压力异常</div>
                            <div class="alarm-level critical">严重</div>
                        </div>
                        <div class="alarm-details">
                            设备: <strong>PLC_02</strong><br>
                            当前压力: <strong style="color: #ef4444;">358.5 kPa</strong> (阈值: 350.0 kPa)<br>
                            持续时间: 2分15秒
                        </div>
                        <div class="alarm-time">⏰ 2025-10-29 14:55:03</div>
                        <div class="alarm-actions">
                            <button class="btn-small">✓ 标记已处理</button>
                            <button class="btn-small">📊 查看数据</button>
                        </div>
                    </div>

                    <!-- 警告 -->
                    <div class="alarm-item warning">
                        <div class="alarm-header">
                            <div class="alarm-title">⚠️ 流量偏高</div>
                            <div class="alarm-level warning">警告</div>
                        </div>
                        <div class="alarm-details">
                            设备: <strong>PLC_01</strong><br>
                            当前流量: <strong style="color: #f59e0b;">52.3 L/min</strong> (阈值: 50.0 L/min)<br>
                            持续时间: 8分41秒
                        </div>
                        <div class="alarm-time">⏰ 2025-10-29 14:48:37</div>
                        <div class="alarm-actions">
                            <button class="btn-small">✓ 标记已处理</button>
                            <button class="btn-small">📊 查看数据</button>
                        </div>
                    </div>

                    <div class="alarm-item warning">
                        <div class="alarm-header">
                            <div class="alarm-title">⚠️ 温度波动异常</div>
                            <div class="alarm-level warning">警告</div>
                        </div>
                        <div class="alarm-details">
                            设备: <strong>PLC_03</strong><br>
                            温度变化率: <strong style="color: #f59e0b;">3.5℃/min</strong> (阈值: 2.0℃/min)<br>
                            检测到快速升温
                        </div>
                        <div class="alarm-time">⏰ 2025-10-29 14:45:22</div>
                        <div class="alarm-actions">
                            <button class="btn-small">✓ 标记已处理</button>
                            <button class="btn-small">📊 查看数据</button>
                        </div>
                    </div>

                    <!-- 信息 -->
                    <div class="alarm-item info">
                        <div class="alarm-header">
                            <div class="alarm-title">ℹ️ 设备连接恢复</div>
                            <div class="alarm-level info">信息</div>
                        </div>
                        <div class="alarm-details">
                            设备: <strong>PLC_03</strong><br>
                            设备已重新连接，数据采集恢复正常
                        </div>
                        <div class="alarm-time">⏰ 2025-10-29 14:42:15</div>
                        <div class="alarm-actions">
                            <button class="btn-small">✓ 标记已读</button>
                        </div>
                    </div>

                    <div class="alarm-item info">
                        <div class="alarm-header">
                            <div class="alarm-title">ℹ️ 数据导出完成</div>
                            <div class="alarm-level info">信息</div>
                        </div>
                        <div class="alarm-details">
                            已成功导出 2025-10-29 的历史数据<br>
                            文件: modbus_data_20251029.csv
                        </div>
                        <div class="alarm-time">⏰ 2025-10-29 14:35:08</div>
                        <div class="alarm-actions">
                            <button class="btn-small">✓ 标记已读</button>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 右侧：阈值设置 -->
            <div class="threshold-settings">
                <div class="section-title">
                    ⚙️ 报警阈值设置
                </div>

                <!-- 温度阈值 -->
                <div class="threshold-item">
                    <div class="threshold-label">
                        🌡️ 温度警告阈值
                    </div>
                    <div class="threshold-input">
                        <input type="number" value="80.0" step="0.1">
                        <span>℃</span>
                    </div>
                    <div style="margin-top: 8px; font-size: 12px; color: #999;">
                        超过此值将触发警告
                    </div>
                </div>

                <div class="threshold-item">
                    <div class="threshold-label">
                        🌡️ 温度严重阈值
                    </div>
                    <div class="threshold-input">
                        <input type="number" value="100.0" step="0.1">
                        <span>℃</span>
                    </div>
                    <div style="margin-top: 8px; font-size: 12px; color: #999;">
                        超过此值将触发严重报警
                    </div>
                </div>

                <!-- 压力阈值 -->
                <div class="threshold-item">
                    <div class="threshold-label">
                        💨 压力警告阈值
                    </div>
                    <div class="threshold-input">
                        <input type="number" value="500.0" step="0.1">
                        <span>kPa</span>
                    </div>
                    <div style="margin-top: 8px; font-size: 12px; color: #999;">
                        超过此值将触发警告
                    </div>
                </div>

                <div class="threshold-item">
                    <div class="threshold-label">
                        💨 压力严重阈值
                    </div>
                    <div class="threshold-input">
                        <input type="number" value="800.0" step="0.1">
                        <span>kPa</span>
                    </div>
                    <div style="margin-top: 8px; font-size: 12px; color: #999;">
                        超过此值将触发严重报警
                    </div>
                </div>

                <!-- 流量阈值 -->
                <div class="threshold-item">
                    <div class="threshold-label">
                        💧 流量警告阈值
                    </div>
                    <div class="threshold-input">
                        <input type="number" value="100.0" step="0.01">
                        <span>L/min</span>
                    </div>
                    <div style="margin-top: 8px; font-size: 12px; color: #999;">
                        超过此值将触发警告
                    </div>
                </div>

                <!-- 保存按钮 -->
                <button class="btn btn-primary" style="width: 100%; margin-top: 20px;">
                    💾 保存设置
                </button>

                <!-- 报警通知设置 -->
                <div style="margin-top: 30px; padding-top: 20px; border-top: 1px solid #e5e7eb;">
                    <div style="font-size: 16px; font-weight: bold; margin-bottom: 15px;">
                        🔔 通知设置
                    </div>
                    <label style="display: flex; align-items: center; gap: 10px; margin-bottom: 10px; cursor: pointer;">
                        <input type="checkbox" checked>
                        <span>启用声音报警</span>
                    </label>
                    <label style="display: flex; align-items: center; gap: 10px; cursor: pointer;">
                        <input type="checkbox" checked>
                        <span>启用弹窗提示</span>
                    </label>
                </div>
            </div>
        </div>
    </div>

    <script>
        // 标签切换
        document.querySelectorAll('.tab').forEach(tab => {
            tab.addEventListener('click', function () {
                document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
                this.classList.add('active');
            });
        });

        // 模拟新报警
        setInterval(() => {
            const badge = document.querySelector('.stat-badge.critical');
            const currentCount = parseInt(badge.textContent);
            badge.textContent = currentCount + Math.floor(Math.random() * 2);
        }, 10000);
    </script>
</body>

</html>